home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 4006 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  1.6 KB

  1. Path: newsfeed.internetmci.com!xmission!news
  2. From: tknarr@xmission.com  ( Todd Knarr )
  3. Newsgroups: comp.lang.c++,comp.lang.c
  4. Subject: Re: Performance: C vs. C++
  5. Date: 27 Jan 1996 04:22:47 GMT
  6. Organization: Chaos Central
  7. Message-ID: <4ec9an$ui@news.xmission.com>
  8. References: <30F6BAAC.12B5@iastate.edu> <4da9pn$a45@news.bridge.net> <4dnpl2$c8g@classic.iinet.com.au> <3105E9DC.1BE3@enermet.fi> <DLr46y.7rH@txnews.amd.com>
  9. Reply-To: tknarr@xmission.com ( Todd Knarr )
  10. NNTP-Posting-Host: slc48.xmission.com
  11. X-Newsreader: IBM NewsReader/2 v1.2
  12.  
  13. In <DLr46y.7rH@txnews.amd.com>, Bret Patterson <faustus> writes:
  14. >Big deal. So c++ does a virtual table lookup, but in order for C to have this ability
  15. >it has to use a switch statement or ifelse construct. I would say with good compiler
  16. >optimization C++ is going to be faster and more readable.
  17.  
  18. With a good compiler, you may not even need the table lookup for a virtual
  19. function. The lookup is needed only when the call is through a pointer or
  20. reference >and< the actual type cannot be determined at compile time. For
  21. things like local variables accessed through pointers, the compiler should
  22. be able to optimize away the vtable lookup completely, reducing those
  23. virtual function calls to non-virtual ones.
  24.  
  25. If it doesn't, then you start hacking the code to reduce the overhead.
  26.  
  27. --
  28. Todd Knarr : tknarr@xmission.com      |  finger for PGP public key
  29.                                       |  Member, USENET Cabal
  30.  
  31. Seriously, I don't want to die just yet.  I don't care how
  32. good-looking they are, I! don't! want! to! die!"
  33.                                         -- Megazone ( UF1 )
  34.  
  35.